-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement x.py test src/tools/clippy --bless
#84189
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
Does this actually work for blessing? Can we hook up x.py to run this? |
I don't know. I don't have time to look into it right now. |
Ok, I updated this to implement |
cargo dev
from inside src/tools/clippyx.py test src/tools/clippy --bless
@Mark-Simulacrum do you know when you'll have a chance to look at this? In the meantime I've been cherry-picking the commit for #84039. |
src/bootstrap/test.rs
Outdated
std::process::exit(1); | ||
} | ||
|
||
println!("running `cargo dev bless` on clippy tests"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for an explicit message here? compiletest blessing is silent -- is there a reason we can't pull that off here?
FWIW I find it a bit interesting that unlike compiletest this is a separate command etc -- maybe @Manishearth or someone familiar with clippy can say why? I'd expect this to be just a flag passed in to compile test when running clippy's tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No particular reason, I'll remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
separate command
I think it's just because the compiletest bless functionality is newer and we just haven't migrated to it yet. But we also have an added feature where cargo dev bless
only updates files that were updated after the last clippy build.
@Manishearth can you either investigate or ping someone who could why we're seeing slightly different test outputs when blessing with this PR (Vec::new -> .., for example; see PR description). |
unsure what's going on here, that looks like Also it could be divergences in compiletest. We tried to convince the compiler team to move compiletest out of tree but they weren't really in favor. |
It's also possible that I just need to rebase over master or something - I haven't spent too much time looking into this. |
That sounds like it's not unlikely 😄 |
I'm sadly not totally up to date when it comes to the |
@jyn514 I checked out your branch, rebased it on top of the current master and tried |
It would be great if you could also apply this patch: diff --git a/src/tools/clippy/clippy_dev/src/new_lint.rs b/src/tools/clippy/clippy_dev/src/new_lint.rs
index d951ca0e630..4676c2affad 100644
--- a/src/tools/clippy/clippy_dev/src/new_lint.rs
+++ b/src/tools/clippy/clippy_dev/src/new_lint.rs
@@ -44,7 +44,7 @@ pub fn create(pass: Option<&str>, lint_name: Option<&str>, category: Option<&str
create_test(&lint).context("Unable to create a test for the new lint")
}
-fn create_lint(lint: &LintData) -> io::Result<()> {
+fn create_lint(lint: &LintData<'_>) -> io::Result<()> {
let (pass_type, pass_lifetimes, pass_import, context_import) = match lint.pass {
"early" => ("EarlyLintPass", "", "use rustc_ast::ast::*;", "EarlyContext"),
"late" => ("LateLintPass", "<'_>", "use rustc_hir::*;", "LateContext"),
@@ -68,7 +68,7 @@ fn create_lint(lint: &LintData) -> io::Result<()> {
write_file(lint.project_root.join(&lint_path), lint_contents.as_bytes())
}
-fn create_test(lint: &LintData) -> io::Result<()> {
+fn create_test(lint: &LintData<'_>) -> io::Result<()> {
fn create_project_layout<P: Into<PathBuf>>(lint_name: &str, location: P, case: &str, hint: &str) -> io::Result<()> {
let mut path = location.into().join(case);
fs::create_dir(&path)?; |
- Add clippy_dev to the rust workspace Before, it would give an error that it wasn't either included or excluded from the workspace: ``` error: current package believes it's in a workspace when it's not: current: /home/joshua/rustc/src/tools/clippy/clippy_dev/Cargo.toml workspace: /home/joshua/rustc/Cargo.toml this may be fixable by adding `src/tools/clippy/clippy_dev` to the `workspace.members` array of the manifest located at: /home/joshua/rustc/Cargo.toml Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest. ``` - Change clippy's copy of compiletest not to special-case rust-lang/rust. Using OUT_DIR confused `clippy_dev` and it couldn't find the test outputs. This is one of the reasons why `cargo dev bless` used to silently do nothing (the others were that `CARGO_TARGET_DIR` and `PROFILE` weren't set appropriately). - Run clippy_dev on test failure I tested this by removing a couple lines from a stderr file, and they were correctly replaced. - Fix clippy_dev warnings
Sure thing, done. |
So no outstanding concerns here? Just checking since I was tagged. |
@jyn514 Can you update the PR description to reflect what I think is the current state, i.e., that this just works? If so, r=me |
Oops, I updated the commit message but not the description. Now fixed. @bors r=Mark-Simulacrum |
📌 Commit 8c25e27 has been approved by |
Implement `x.py test src/tools/clippy --bless` - Add clippy_dev to the rust workspace Before, it would give an error that it wasn't either included or excluded from the workspace: ``` error: current package believes it's in a workspace when it's not: current: /home/joshua/rustc/src/tools/clippy/clippy_dev/Cargo.toml workspace: /home/joshua/rustc/Cargo.toml this may be fixable by adding `src/tools/clippy/clippy_dev` to the `workspace.members` array of the manifest located at: /home/joshua/rustc/Cargo.toml Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest. ``` - Change clippy's copy of compiletest not to special-case rust-lang/rust. Using OUT_DIR confused `clippy_dev` and it couldn't find the test outputs. This is one of the reasons why `cargo dev bless` used to silently do nothing (the others were that `CARGO_TARGET_DIR` and `PROFILE` weren't set appropriately). - Run clippy_dev on test failure I tested this by removing a couple lines from a stderr file, and they were correctly replaced. - Fix clippy_dev warnings
⌛ Testing commit 8c25e27 with merge 267ddd8719e80bbcdf8613881b8f87788de74412... |
💔 Test failed - checks-actions |
A job failed! Check out the build log: (web) (plain) Click to see the possible cause of the failure (guessed by this bot)
|
@bors retry |
☀️ Test successful - checks-actions |
Implement `x.py test src/tools/clippy --bless` - Add clippy_dev to the rust workspace Before, it would give an error that it wasn't either included or excluded from the workspace: ``` error: current package believes it's in a workspace when it's not: current: /home/joshua/rustc/src/tools/clippy/clippy_dev/Cargo.toml workspace: /home/joshua/rustc/Cargo.toml this may be fixable by adding `src/tools/clippy/clippy_dev` to the `workspace.members` array of the manifest located at: /home/joshua/rustc/Cargo.toml Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest. ``` - Change clippy's copy of compiletest not to special-case rust-lang/rust. Using OUT_DIR confused `clippy_dev` and it couldn't find the test outputs. This is one of the reasons why `cargo dev bless` used to silently do nothing (the others were that `CARGO_TARGET_DIR` and `PROFILE` weren't set appropriately). - Run clippy_dev on test failure I tested this by removing a couple lines from a stderr file, and they were correctly replaced. - Fix clippy_dev warnings
I'm making some changes to the structured suggestion output, and it seems like I'm unable to get my local environment to fail the tests that are failing in CI. I'm not sure if it is because |
That should work. If it's not, I don't know what's going wrong, sorry. |
I just lost two hours to being in the wrong branch 🤦♂️ Edit: BTW, thank you @jyn514 for improving the workflow here! Had it not been for my PEBKAC problem, the current behavior is almost perfect. |
Add clippy_dev to the rust workspace
Before, it would give an error that it wasn't either included or
excluded from the workspace:
Change clippy's copy of compiletest not to special-case
rust-lang/rust. Using OUT_DIR confused
clippy_dev
and it couldn't findthe test outputs. This is one of the reasons why
cargo dev bless
usedto silently do nothing (the others were that
CARGO_TARGET_DIR
andPROFILE
weren't set appropriately).Run clippy_dev on test failure
I tested this by removing a couple lines from a stderr file, and they
were correctly replaced.